using ApplicationBase.Core;
using ApplicationBase.Core.Email;
using ApplicationBase.Core.Web.Extensions;
using Autofac.Extensions.DependencyInjection;
using Autofac;
using EmailService.WebAPI;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDefaultControllers();
builder.Services.AddDefaultSwagger();

builder.Services.Configure<SMTPEmailOptions>(builder.Configuration.GetSection("SMTPOptions"));

//AutoFac
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
builder.Host.ConfigureContainer<ContainerBuilder>(containerBuilder =>
{
    containerBuilder.RegisterModule<BaseModule>();
    containerBuilder.RegisterModule<AppModule>();
});

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
